

//时间复杂度为n2

let nums = [3,2,1,2,3,4,3,4,5,9,10,11]
let k = 3


var isPossibleDivide = function(nums, k) {
    if(nums.length%k==0){
        nums.sort((a,b) => {
            return a-b;
        })
        while(nums.length>0){
            for(let i=1;i<k;i++){
                let n = nums.indexOf(nums[0]+i)
                if(n>0){
                    nums.splice(n,1)
                }
                else{
                    return false;
                }
            }
            nums.shift()
        }
        return true;
    }
    else{
        return false;
    }
    
};

console.log(isPossibleDivide(nums,k));
